home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 38 / Amiga Format CD38 (1999-03-15)(Future Publishing)(GB)(Track 1 of 3)[!][issue 1999-04].iso / -screenplay- / hd_installers / -whdload- / whdload_dev / src / slave-examples / oscar.asm < prev    next >
Assembly Source File  |  1998-07-16  |  4KB  |  168 lines

  1. ;*---------------------------------------------------------------------------
  2. ;  :Program.    oscar.asm
  3. ;  :Contents.    Slave for "Oscar"
  4. ;  :Author.    Wepl
  5. ;  :Version.    $Id: oscar.asm 1.3 1998/06/27 23:50:34 jah Exp jah $
  6. ;  :History.    20.05.96
  7. ;        16.06.97 updated for slave version 2
  8. ;        15.08.97 update for key managment
  9. ;  :Requires.    -
  10. ;  :Copyright.    Public Domain
  11. ;  :Language.    68000 Assembler
  12. ;  :Translator.    Barfly V1.131
  13. ;  :To Do.
  14. ;---------------------------------------------------------------------------*
  15.  
  16.     INCDIR    Includes:
  17.     INCLUDE    whdload.i
  18.  
  19.     IFD BARFLY
  20.     OUTPUT    "wart:oscar/oscar.slave"
  21.     BOPT    O+ OG+                ;enable optimizing
  22.     BOPT    ODd- ODe-            ;disable mul optimizing
  23.     BOPT    w4-                ;disable 64k warnings
  24.     SUPER                    ;disable supervisor warnings
  25.     ENDC
  26.  
  27. ;======================================================================
  28.  
  29. _base        SLAVE_HEADER            ;ws_Security + ws_ID
  30.         dc.w    4            ;ws_Version
  31.         dc.w    WHDLF_NoError        ;ws_flags
  32. _upchip        dc.l    $177000            ;ws_BaseMemSize
  33.         dc.l    $300            ;ws_ExecInstall
  34.         dc.w    _Start-_base        ;ws_GameLoader
  35.         dc.w    _dir-_base        ;ws_CurrentDir
  36.         dc.w    0            ;ws_DontCache
  37. _keydebug    dc.b    0            ;ws_keydebug
  38. _keyexit    dc.b    $59            ;ws_keyexit = F10
  39.  
  40. _dir        dc.b    "data",0
  41.  
  42. ;======================================================================
  43.  
  44.     IFD BARFLY
  45.         dc.b    "$VER: Oscar.Slave by Wepl "
  46.     DOSCMD    "WDate >T:date"
  47.     INCBIN    "T:date"
  48.         dc.b    0
  49.     ENDC
  50.     EVEN
  51.  
  52. ;======================================================================
  53. _Start        ;    A0 = resident loader
  54. ;======================================================================
  55.  
  56.         lea    (_resload,pc),a1
  57.         move.l    a0,(a1)            ;save for later using
  58.  
  59.         move.l    #CACRF_EnableI,d0    ;enable instruction cache
  60.         move.l    d0,d1            ;mask
  61.         jsr    (resload_SetCACR,a0)
  62.  
  63.         lea    _10,a0
  64.         move.l    (.freemem),a1
  65.         move.l    (_resload),a2
  66.         jsr    (resload_LoadFileDecrunch,a2)
  67.         lea    .freemem,a0
  68.         add.l    d0,(a0)
  69.  
  70.         patch    $400+$8b4e,.allocmem    ;emulate this
  71.         skip    $2a8-$276,$400+$276    ;disable some os-stuff
  72.         patch    $400+$7b1a,_loader
  73.         add.l    #$99fc+$400-$9b64,$838+$400    ;copylock
  74.         jmp    $43e            ;start the dance
  75.  
  76. .allocmem    lea    .freemem,a0        ;this emulates "exec.AllocMem"
  77.         move.l    (a0),a1
  78.         add.l    d0,(a0)
  79.         move.l    (a0),d1
  80.         cmp.l    (_upchip),d1
  81.         blo    .1
  82.     illegal                    ;if basemem must increased
  83. .1        move.l    a1,a0
  84.         addq.l    #7,d0
  85.         lsr.l    #3,d0
  86. .clr        clr.l    (a0)+
  87.         clr.l    (a0)+
  88.         subq.l    #1,d0
  89.         bne    .clr
  90.         move.l    a1,d0
  91.         rts
  92.  
  93. .freemem    dc.l    $400            ;start point of free memory
  94.  
  95. _10        dc.b    "exe",0
  96.     EVEN
  97.  
  98. ;--------------------------------
  99.  
  100. _loader        addq.l    #4,a0            ;skip "df0:"
  101.         move.l    a2,-(a7)
  102.         move.l    (_resload),a2
  103.         jsr    (resload_LoadFileDecrunch,a2)
  104.         move.l    (a7)+,a2
  105.         bsr    _kinit
  106.         moveq    #0,d0            ;return code
  107.         rts
  108.  
  109. ;--------------------------------
  110.  
  111. _kinit        movem.l    a0-a1,-(a7)
  112.         lea    (_keyboard,pc),a1
  113.         cmp.l    $68,a1
  114.         beq    .q
  115.         lea    (_realint68,pc),a0
  116.         move.l    $68,(a0)
  117.         move.l    a1,$68
  118. .q        movem.l    (a7)+,a0-a1
  119.         rts
  120.  
  121. _realint68    dc.l    0
  122.  
  123. _keyboard    move.l    d0,-(a7)
  124.         move.b    $bfec01,d0
  125.         ror.b    #1,d0
  126.         not.b    d0
  127.  
  128. ; RAW-Key-Codes:
  129. ;    ESC    $45
  130. ;    DEL    $46
  131. ;    F1..F10    $50..$59
  132. ;    HELP    $5f
  133.  
  134.         cmp.b    (_keydebug),d0
  135.         bne    .1
  136.         move.l    (a7)+,d0
  137.         move.w    (a7),(6,a7)        ;sr
  138.         move.l    (2,a7),(a7)        ;pc
  139.         clr.w    (4,a7)            ;ext.l sr
  140.         bra    _debug            ;coredump & quit
  141. .1
  142.         cmp.b    (_keyexit),d0
  143.         beq    _exit            ;exit
  144.         cmp.b    #$45,d0
  145.         beq    _exit            ;exit
  146.  
  147.         move.l    (a7)+,d0
  148.         move.l    (_realint68),-(a7)    ;enter orginal rou.
  149.         rts
  150.  
  151. ;--------------------------------
  152.  
  153. _resload    dc.l    0            ;address of resident loader
  154.  
  155. ;--------------------------------
  156.  
  157. _exit        pea    TDREASON_OK
  158.         bra    _end
  159. _debug        pea    TDREASON_DEBUG
  160. _end        move.l    (_resload),-(a7)
  161.         add.l    #resload_Abort,(a7)
  162.         rts
  163.  
  164. ;======================================================================
  165.  
  166.     END
  167.  
  168.